package impl;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * Created by zuoxiao
 * on 2019/6/29.
 */
@Aspect
public class TestAspect {

    @Pointcut("execution(* impl.AopTestImpl.printInfo(..))")
    void print() {
    }

    @Before("print()"+"&& args(s)")
    public void before(String s) {
        System.out.println(s+"-------before method---------");
    }

    @After("print()")
    public void after() {
        System.out.println("-------after method---------");

    }

    @AfterReturning("print()")
    public void afterReturning() {
        System.out.println("-------afterReturning method---------");

    }

    @AfterThrowing("print()")
    public void afterThrowing() {
        System.out.println("-------afterThrowing method---------");

    }

     @Around("print()")
    public void around(ProceedingJoinPoint joinPoint){
    System.out.println("-------before around---------");
        try {
            joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("-------after around---------");
    }

}
